package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsLt;
import com.ruoyi.system.service.IDsLtService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天记录
Controller
 *
 * @author tyro
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/system/lt")
public class DsLtController extends BaseController
{
    @Autowired
    private IDsLtService dsLtService;

    /**
     * 查询聊天记录
列表
     */
    @PreAuthorize("@ss.hasPermi('system:lt:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsLt dsLt)
    {
        startPage();
        List<DsLt> list = dsLtService.selectDsLtList(dsLt);
        return getDataTable(list);
    }

    /**
     * 导出聊天记录
列表
     */
    @PreAuthorize("@ss.hasPermi('system:lt:export')")
    @Log(title = "聊天记录 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsLt dsLt)
    {
        List<DsLt> list = dsLtService.selectDsLtList(dsLt);
        ExcelUtil<DsLt> util = new ExcelUtil<DsLt>(DsLt.class);
        util.exportExcel(response, list, "聊天记录 数据");
    }

    /**
     * 获取聊天记录
详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:lt:query')")
    @GetMapping(value = "/{ltId}")
    public AjaxResult getInfo(@PathVariable("ltId") Long ltId)
    {
        return success(dsLtService.selectDsLtByLtId(ltId));
    }

    /**
     * 新增聊天记录

     */
    @PreAuthorize("@ss.hasPermi('system:lt:add')")
    @Log(title = "聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsLt dsLt)
    {
        return toAjax(dsLtService.insertDsLt(dsLt));
    }

    /**
     * 修改聊天记录

     */
    @PreAuthorize("@ss.hasPermi('system:lt:edit')")
    @Log(title = "聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsLt dsLt)
    {
        return toAjax(dsLtService.updateDsLt(dsLt));
    }

    /**
     * 删除聊天记录

     */
    @PreAuthorize("@ss.hasPermi('system:lt:remove')")
    @Log(title = "聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ltIds}")
    public AjaxResult remove(@PathVariable Long[] ltIds)
    {
        return toAjax(dsLtService.deleteDsLtByLtIds(ltIds));
    }
}
